﻿using Microsoft.WowAddonStudio.FrameXml.Serialization.LayoutFrames;
using NUnit.Framework;

namespace Microsoft.WowAddonStudio.FrameXml.Serialization.Tests
{
	[TestFixture]
	public class LayoutFrameTest : SerializationTestBase<LayoutFrame>
	{
		[Test]
		public void SizeAnchorTest()
		{
			InitializeTestEntity("Simple/LayoutFrame.xml");

			Assert.AreEqual("TestLayoutFrame", TestEntity.Name);
            Assert.IsNotNull(TestEntity.SizeDimension);
            Assert.IsNotNull(TestEntity.SizeDimension.AbsDimension);
			Assert.IsNotNull(TestEntity.Anchors);
			Assert.AreEqual(1, TestEntity.Anchors.Length);

			// Ui/LayoutFrame[0]/Anchors/Anchor[0]
			Anchor anchor = TestEntity.Anchors[0];

			Assert.AreEqual(FramePoint.TopLeft, anchor.Point);
			Assert.IsNotNull(anchor.Offset);
			Assert.IsNotNull(anchor.Offset.AbsDimension);
		}

		/// <summary>
		/// Gets the entity to be tested from a <see cref="Ui"/> instance.
		/// </summary>
		/// <param name="ui">The ui instance.</param>
		/// <returns>
		/// An instance of the <typeparamref name="TSerializationObject"/> class.
		/// </returns>
		protected override LayoutFrame GetTestEntity(Ui ui)
		{
			Assert.IsNotNull(ui.LayoutFrames);
			Assert.AreEqual(1, ui.LayoutFrames.Count);

			// Ui/LayoutFrame[0]
			return ui.LayoutFrames[0];
		}
	}
}